import yaml;
import globals

class yaml_configuration :
    configRout=None;
    configFile=None;

    def __init__(self, configRout):
        #print configRout
        configFileDescriptor = open(configRout,'r');
        try:
            self.configFile = yaml.load(configFileDescriptor);
        except yaml.YAMLError:
            print "error in configuration file"

    def getConfiguration(self):
        return self.configFile['configuration']

    def getAuthoServer(self):
        globals.AUTH_SERVER_IP=self.configFile['authoserver'][0]['ip']
        globals.AUTH_SERVER_PORT=self.configFile['authoserver'][1]['port']
        return self.configFile['authoserver']
if __name__ == '__main__':
    file = yaml_configuration('demo.yaml')
    c= file.getConfiguration()
    index = raw_input('Enter index: ')
    print c[int(index)]['group']
